$(function () {
    // 注册 hxmui 并固定白板主题模式
    Vue.use(window.hxmui, {
        themeMode: 'light'
    });
    let vueInit = new Vue({
        // 变量在mixin.js里面
        el: '#vuewrap',
        data(){
          return{
              allQuesData:[],
              allQuestionTotal:null,
              allQuesListHasMore:true,
              pageSize:10,
              pargeNo: 1,
          }
        },
        created(){
            this.queryData()
        },
        mounted(){

        },
        computed:{

        },
        filter:{

        },
        methods:{
            //查询数据
            queryData(code){
                code && this.$pageStatus.loading();
                if(!this.allQuesListHasMore){
                    return
                }
                let _this=this
                let obj = {
                    pageSize:_this.pageSize,
                    pageNo:_this.pargeNo
                }

                ajax(hxmConfig.detailApi,  JSON.stringify(obj),
                    function (res) {
                        if (res.status_code == 0) {
                            _this.pargeNo++
                            _this.allQuesData=[..._this.allQuesData,...res.data.qaList]
                            if(res.data.qaList.length<10){
                                _this.allQuesListHasMore = false
                            }
                            _this.allQuestionTotal=res.data.totalSize
                            code && _this.$pageStatus.close();
                        } else {
                            _this.$toast(res.errormsg);
                            _this.failLoading()
                        }
                    },
                    function (err) {
                        console.log(err)
                        _this.failLoading()
                    },'post',true,'application/json'
                )
            },
            //上滑加载
            handleScrollToBottom(isReturnBottom){
                isReturnBottom && this.queryData();
            },
            //加载失败
            failLoading(){
                this.$pageStatus.fail(() => {
                    window.location.reload()
                });
            },
        },
    })
})